function conform(orig='', patt, {exactMatching=true}={}) {

  const origList = orig.split('/').reverse();
  const pattList = patt.split('/').reverse();

  if (exactMatching) {
    if (!patt.includes('**') && origList.length !== pattList.length) {
      return false;
    }
  }

  let res = true;
  while (pattList.length > 0 && res) {

    const origSeg = origList.length > 0 ? origList.pop().replace(/[ .]/g, '') : undefined;
    const pattSeg = pattList.pop();

    // else we proceed to a normal matching. if the segments at same
    // position doesn't match, then a false result will be formed, and
    // the loop will stop.

    res = res && [origSeg, '*', '**'].includes(pattSeg);

    if (pattSeg === '**') {
      break;
    }
  }

  return res;
}

export default conform;